#ifndef RTE_WINDOWS_SOEM_H
#define RTE_WINDOWS_SOEM_H
#ifdef USE_SOEM

#include "osal_defs.h"

#include "soem/ethercat.h"

#endif
#ifdef __cplusplus
extern "C"
{
#endif

#include <stdint.h>
typedef unsigned char u8;
typedef unsigned short u16;

typedef struct {
    uint32_t Vendor_ID;
    uint32_t Product_code;
    uint32_t Revision;

    int (*config)();
} soem_slave;
typedef struct {
    soem_slave *slave;
    uint32_t slave_nrs;
    const char *ifname;
    u8 *IOMAP;
    u16 IOmap_nrs;
    void *thd;
    uint32_t flags;
} soem_master_t;
#define SOEM_RUNNING 0x1
typedef struct {
    /*
     * 初始化
     */
    soem_master_t *(*init)(int io_size);

    /*
     * 获取数据
     */
    void (*retrieve)(soem_master_t *);

    /*
     * 发布数据
     */
    void (*publish)(soem_master_t *);

    /*
     * @brief cleanup
     */
    void (*cleanup)(soem_master_t *);

    int (*SDOUpload)(int slave, int index, int subindex, int size, void *data);

    int (*SDODownload)(int slave, int index, int subindex, int size, void *data);
} soem_t;
extern const soem_t soem_abi;
#ifdef __cplusplus
};
#endif

#endif // RTE_WINDOWS_SOEM_H
